﻿using CoachingOrganizer.Toolkit.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CoachingOrganizer.Logic.Models.Tools.MoneyCalculation
{
    public class OccasionalMoneyFlowItemModel
    {
        private string _name;
        private decimal _amount;
        private DateTime _time = DateTime.Now;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        public decimal Amount
        {
            get { return _amount; }
            set { _amount = value; }
        }

        public DateTime Time
        {
            get { return _time; }
            set { _time = value; }
        }

        internal Func<ActionResult> RemoveDelegate;

        internal Func<ActionResult> SaveDelegate;

        public OccasionalMoneyFlowItemModel()
        {

        }

        public async Task<ActionResult> Remove()
        {
            Func<ActionResult> removeDelegate = RemoveDelegate;
            return removeDelegate == null ? ActionResult.GetErrorResult(new NotSupportedException()) : await Task.Run(() => removeDelegate());
        }

        public async Task<ActionResult> Save()
        {
            Func<ActionResult> saveDelegate = SaveDelegate;
            return saveDelegate == null ? ActionResult.GetErrorResult(new NotSupportedException()) : await Task.Run(() => saveDelegate());
        }
    }
}
